package com.tbit.uqbike.object.pojo;

import java.util.HashMap;
import java.util.Map;

/**
 * @author MyWin E-mail:335918956@qq.com
 * @version 1.0
 * @createTime 2019-12-17 18:04
 */
public class BikeStatus {
    public static final String PRO_TOTAL = "total";
    public static final String PRO_USE = "use";
    public static final String PRO_FAULT = "fault";
    public static final String PRO_ABNORMAL = "abnormal";
    public static final String PRO_NORMAL = "normal";
    /**
     * 是否正在使用
     */
    private Boolean isUse;
    /**
     * 是否异常
     */
    private Boolean isAbnormal;
    /**
     * 是否故障
     */
    private Boolean isFault;

    public static Map<String, Integer> initMap() {
        Map<String, Integer> map = new HashMap<>();
        map.put(PRO_TOTAL, 0);
        map.put(PRO_USE, 0);
        map.put(PRO_FAULT, 0);
        map.put(PRO_ABNORMAL, 0);
        map.put(PRO_NORMAL, 0);
        return map;
    }

    public static Map<String, Integer> statItem(Map<String, Integer> map, BikeStatus bs) {
        incMapKey(map, PRO_TOTAL);
        if (bs.isUse) {
            incMapKey(map, PRO_USE);
        }
        if (bs.isFault) {
            incMapKey(map, PRO_FAULT);
        }
        if (bs.isAbnormal) {
            incMapKey(map, PRO_ABNORMAL);
        }
        if (!bs.isUse && !bs.isFault && !bs.isAbnormal) {
            incMapKey(map, PRO_NORMAL);
        }
        return map;
    }

    private static void incMapKey(Map<String, Integer> map, String key) {
        map.put(key, map.get(key) + 1);
    }

    public Boolean getUse() {
        return isUse;
    }

    public void setUse(Boolean use) {
        isUse = use;
    }

    public Boolean getAbnormal() {
        return isAbnormal;
    }

    public void setAbnormal(Boolean abnormal) {
        isAbnormal = abnormal;
    }

    public Boolean getFault() {
        return isFault;
    }

    public void setFault(Boolean fault) {
        isFault = fault;
    }
}
